package com.example.lib.io;

import java.io.FileReader;
import java.io.IOException;

/**
 * 读取一个.java文件，并打印在控制台。
 */
public class g_io_FileReadTest_18_12 {
    public static void main(String[] args) {

        FileReader fr = null;

        try {
            fr = new FileReader("lib/src/main/java/com/example/lib/io/f_io_FileReader_18_11.java");

            char[] buf = new char[1024];
            int num = 0;
            while ((num = fr.read(buf)) != -1) {
                System.out.println(new String(buf, 0, num));
            }

        } catch (IOException e) {
            System.out.println(e.toString());
        } finally {
            try {
                if (fr != null) {
                    fr.close();
                }
            } catch (IOException e) {
                System.out.println(e.toString());
            }

        }
    }
}
